home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wback.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  101 lines

  1. ; $Id: wback.pro,v 1.4 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a widget that performs a timer task.
  7. ; Timer tasks are performed after the registered timer expires.
  8. ; For example, things like animations can run under timer control
  9. ; without forcing other widgets to be inactive.
  10.  
  11. ; Here, a text window appears and the current system time is displayed 
  12. ; repeatedly each second.  Select the "Done" button to exit.
  13.  
  14.  
  15.  
  16.  
  17. PRO wback_event, event
  18. ; This is the event handler for a background task widget.
  19.  
  20. ; The COMMON block is used because the event handler and the timer
  21. ; both need the widget id of the text widget:
  22.  
  23. COMMON wbackblock, text1
  24.  
  25. IF TAG_NAMES(event, /STRUCTURE_NAME) EQ 'WIDGET_TIMER' THEN BEGIN
  26. ; This is the task that the widget performs when timer expires
  27.  
  28. temp_string = SYSTIME(0)
  29. WIDGET_CONTROL, text1, SET_VALUE=temp_string, /APPEND
  30.  
  31. ; Re-register the timer
  32. WIDGET_CONTROL, event.top, /TIMER
  33.  
  34. RETURN
  35. ENDIF
  36.  
  37. ; If a widget has been selected, put its User Value into 'eventval':
  38.  
  39. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  40.  
  41. ; Perform actions based on the user value of the event:
  42.  
  43. CASE eventval OF
  44.  
  45.    'DONE' : WIDGET_CONTROL, event.top, /DESTROY
  46.  
  47.    'ERASE': WIDGET_CONTROL, text1, SET_VALUE = ''
  48.  
  49. ENDCASE
  50.  
  51. END
  52.  
  53.  
  54.  
  55. PRO wback, GROUP=GROUP
  56.  
  57. ; This is the procedure that creates a widget with a timer
  58.  
  59. ; The COMMON block is used because the event handler needs
  60. ; the widget id of the text widget:
  61.  
  62. COMMON wbackblock, text1
  63.  
  64. ; A top-level base widget with the title "Timer Widget Example"
  65. ; is created:
  66.  
  67. base = WIDGET_BASE(TITLE = 'Timer Widget Example', $
  68.     /COLUMN)
  69.  
  70. ; Make the 'DONE' button:
  71.  
  72. button1 = WIDGET_BUTTON(base, $
  73.         UVALUE = 'DONE', $
  74.         VALUE = 'DONE')
  75.  
  76. ; Make the text widget:
  77.  
  78. text1 = WIDGET_TEXT(base, $        ; create a display only text widget
  79.         XSIZE=30, $
  80.         YSIZE=30, $
  81.         /SCROLL)
  82.  
  83. ; Make a button which will clear the text file.
  84.  
  85. button2 = WIDGET_BUTTON(base, $
  86.         UVALUE = 'ERASE', $
  87.         VALUE = 'ERASE')
  88.  
  89. ; Realize the widgets:
  90. WIDGET_CONTROL, base, /REALIZE
  91.  
  92. ; Register the timer
  93. WIDGET_CONTROL, base, /TIMER
  94.  
  95. ; Hand off control of the widget to the XMANAGER
  96. XMANAGER, "wback", base, GROUP_LEADER=GROUP, /NO_BLOCK
  97.  
  98. END
  99.  
  100.  
  101.